﻿using System.Collections.Generic;
using Roslyn.Compilers.CSharp;

namespace RoslynHelper
{
    public static class AccessorDeclaration
    {
        public static AccessorDeclarationSyntax DefineBody(this AccessorDeclarationSyntax node, StatementSyntax statement)
        {
            return DefineBody(node, new [] { statement });
        }

        public static AccessorDeclarationSyntax DefineBody(this AccessorDeclarationSyntax node, IEnumerable<StatementSyntax> statements)
        {
            return Syntax.AccessorDeclaration(
                kind: node.Kind,
                attributes: node.Attributes,
                modifiers: node.Modifiers,
                keyword: node.Keyword,
                bodyOpt: Syntax.Block(
                    statements: Syntax.List<StatementSyntax>(statements)));
        }
    }
}
